/*****
author : sailing
date: 2016/11/20
******/
import Config from './config'
import tools from './tools'
export default {
  setNodeStyle (cy) {
    cy.style()
      .selector('node')
      .style({
        'shape': 'rectangle',
        'width': '35px',
        'height': '35px'
      })
      .update()
    console.log('xxxxxxxxxxxxxxxxx')
    this.setImage(cy)
    /*
    var fw = cy.elements().floydWarshall()
    var pa = fw.path('#n11', '#n15').select()
    console.log('pa:', pa.data())
    for (var i = 0; i < pa.length; i++) {
      var ele = pa[i].data()
      if (pa[i].isEdge()) {
        pa[i].style({
          'width': 1,
          'target-arrow-shape': 'triangle',
          'line-color': 'red',
          'curve-style': 'haystack',
          'label': 'data(label)',
          'haystack-radius': 9,
          'target-arrow-color': 'red'
        })
      }
      console.log('eleeeeeeeeee:', ele)
    }
    */
  },
  setImage (cy) {
    cy.nodes(function (i, node) {
      var data = node.data()
      if (data['type']) {
        var image = tools.getImgPath(data['type'])
        try {
          node.style({
            'width': '35px',
            'height': '35px',
            'background-image': image
          })
        } catch (e) {
          console.log(e)
        } 
      }
    })
  }
}
